3.1.7 \(\int x^2 \tan ^2(a+b x) \, dx\) [7]

Optimal. Leaf size=73 \[ -\frac {i x^2}{b}-\frac {x^3}{3}+\frac {2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}-\frac {i \text {PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^3}+\frac {x^2 \tan (a+b x)}{b} \]

[Out]

-I*x^2/b-1/3*x^3+2*x*ln(1+exp(2*I*(b*x+a)))/b^2-I*polylog(2,-exp(2*I*(b*x+a)))/b^3+x^2*tan(b*x+a)/b

________________________________________________________________________________________

Rubi [A]
time = 0.08, antiderivative size = 73, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, integrand size = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.500, Rules used = {3801, 3800, 2221, 2317, 2438, 30} \begin {gather*} -\frac {i \text {Li}_2\left (-e^{2 i (a+b x)}\right )}{b^3}+\frac {2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac {x^2 \tan (a+b x)}{b}-\frac {i x^2}{b}-\frac {x^3}{3} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[x^2*Tan[a + b*x]^2,x]

[Out]

((-I)*x^2)/b - x^3/3 + (2*x*Log[1 + E^((2*I)*(a + b*x))])/b^2 - (I*PolyLog[2, -E^((2*I)*(a + b*x))])/b^3 + (x^
2*Tan[a + b*x])/b

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 2221

Int[(((F_)^((g_.)*((e_.) + (f_.)*(x_))))^(n_.)*((c_.) + (d_.)*(x_))^(m_.))/((a_) + (b_.)*((F_)^((g_.)*((e_.) +
 (f_.)*(x_))))^(n_.)), x_Symbol] :> Simp[((c + d*x)^m/(b*f*g*n*Log[F]))*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x]
 - Dist[d*(m/(b*f*g*n*Log[F])), Int[(c + d*x)^(m - 1)*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x], x] /; FreeQ[{F,
a, b, c, d, e, f, g, n}, x] && IGtQ[m, 0]

Rule 2317

Int[Log[(a_) + (b_.)*((F_)^((e_.)*((c_.) + (d_.)*(x_))))^(n_.)], x_Symbol] :> Dist[1/(d*e*n*Log[F]), Subst[Int
[Log[a + b*x]/x, x], x, (F^(e*(c + d*x)))^n], x] /; FreeQ[{F, a, b, c, d, e, n}, x] && GtQ[a, 0]

Rule 2438

Int[Log[(c_.)*((d_) + (e_.)*(x_)^(n_.))]/(x_), x_Symbol] :> Simp[-PolyLog[2, (-c)*e*x^n]/n, x] /; FreeQ[{c, d,
 e, n}, x] && EqQ[c*d, 1]

Rule 3800

Int[((c_.) + (d_.)*(x_))^(m_.)*tan[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[I*((c + d*x)^(m + 1)/(d*(m + 1))), x
] - Dist[2*I, Int[(c + d*x)^m*(E^(2*I*(e + f*x))/(1 + E^(2*I*(e + f*x)))), x], x] /; FreeQ[{c, d, e, f}, x] &&
 IGtQ[m, 0]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rubi steps

\begin {align*} \int x^2 \tan ^2(a+b x) \, dx &=\frac {x^2 \tan (a+b x)}{b}-\frac {2 \int x \tan (a+b x) \, dx}{b}-\int x^2 \, dx\\ &=-\frac {i x^2}{b}-\frac {x^3}{3}+\frac {x^2 \tan (a+b x)}{b}+\frac {(4 i) \int \frac {e^{2 i (a+b x)} x}{1+e^{2 i (a+b x)}} \, dx}{b}\\ &=-\frac {i x^2}{b}-\frac {x^3}{3}+\frac {2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac {x^2 \tan (a+b x)}{b}-\frac {2 \int \log \left (1+e^{2 i (a+b x)}\right ) \, dx}{b^2}\\ &=-\frac {i x^2}{b}-\frac {x^3}{3}+\frac {2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac {x^2 \tan (a+b x)}{b}+\frac {i \text {Subst}\left (\int \frac {\log (1+x)}{x} \, dx,x,e^{2 i (a+b x)}\right )}{b^3}\\ &=-\frac {i x^2}{b}-\frac {x^3}{3}+\frac {2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}-\frac {i \text {Li}_2\left (-e^{2 i (a+b x)}\right )}{b^3}+\frac {x^2 \tan (a+b x)}{b}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(189\) vs. \(2(73)=146\).
time = 6.16, size = 189, normalized size = 2.59 \begin {gather*} -\frac {x^3}{3}+\frac {\csc (a) \left (b^2 e^{-i \text {ArcTan}(\cot (a))} x^2-\frac {\cot (a) \left (i b x (-\pi -2 \text {ArcTan}(\cot (a)))-\pi \log \left (1+e^{-2 i b x}\right )-2 (b x-\text {ArcTan}(\cot (a))) \log \left (1-e^{2 i (b x-\text {ArcTan}(\cot (a)))}\right )+\pi \log (\cos (b x))-2 \text {ArcTan}(\cot (a)) \log (\sin (b x-\text {ArcTan}(\cot (a))))+i \text {PolyLog}\left (2,e^{2 i (b x-\text {ArcTan}(\cot (a)))}\right )\right )}{\sqrt {1+\cot ^2(a)}}\right ) \sec (a)}{b^3 \sqrt {\csc ^2(a) \left (\cos ^2(a)+\sin ^2(a)\right )}}+\frac {x^2 \sec (a) \sec (a+b x) \sin (b x)}{b} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[x^2*Tan[a + b*x]^2,x]

[Out]

-1/3*x^3 + (Csc[a]*((b^2*x^2)/E^(I*ArcTan[Cot[a]]) - (Cot[a]*(I*b*x*(-Pi - 2*ArcTan[Cot[a]]) - Pi*Log[1 + E^((
-2*I)*b*x)] - 2*(b*x - ArcTan[Cot[a]])*Log[1 - E^((2*I)*(b*x - ArcTan[Cot[a]]))] + Pi*Log[Cos[b*x]] - 2*ArcTan
[Cot[a]]*Log[Sin[b*x - ArcTan[Cot[a]]]] + I*PolyLog[2, E^((2*I)*(b*x - ArcTan[Cot[a]]))]))/Sqrt[1 + Cot[a]^2])
*Sec[a])/(b^3*Sqrt[Csc[a]^2*(Cos[a]^2 + Sin[a]^2)]) + (x^2*Sec[a]*Sec[a + b*x]*Sin[b*x])/b

________________________________________________________________________________________

Maple [A]
time = 0.09, size = 108, normalized size = 1.48

method result size
risch \(-\frac {x^{3}}{3}+\frac {2 i x^{2}}{b \left ({\mathrm e}^{2 i \left (b x +a \right )}+1\right )}-\frac {2 i x^{2}}{b}-\frac {4 i a x}{b^{2}}-\frac {2 i a^{2}}{b^{3}}+\frac {2 x \ln \left ({\mathrm e}^{2 i \left (b x +a \right )}+1\right )}{b^{2}}-\frac {i \polylog \left (2, -{\mathrm e}^{2 i \left (b x +a \right )}\right )}{b^{3}}+\frac {4 a \ln \left ({\mathrm e}^{i \left (b x +a \right )}\right )}{b^{3}}\) \(108\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(x^2*tan(b*x+a)^2,x,method=_RETURNVERBOSE)

[Out]

-1/3*x^3+2*I*x^2/b/(exp(2*I*(b*x+a))+1)-2*I/b*x^2-4*I/b^2*a*x-2*I/b^3*a^2+2*x*ln(exp(2*I*(b*x+a))+1)/b^2-I*pol
ylog(2,-exp(2*I*(b*x+a)))/b^3+4/b^3*a*ln(exp(I*(b*x+a)))

________________________________________________________________________________________

Maxima [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 257 vs. \(2 (62) = 124\).
time = 0.61, size = 257, normalized size = 3.52 \begin {gather*} \frac {i \, b^{3} x^{3} + 6 \, {\left (b x \cos \left (2 \, b x + 2 \, a\right ) + i \, b x \sin \left (2 \, b x + 2 \, a\right ) + b x\right )} \arctan \left (\sin \left (2 \, b x + 2 \, a\right ), \cos \left (2 \, b x + 2 \, a\right ) + 1\right ) + {\left (i \, b^{3} x^{3} - 6 \, b^{2} x^{2}\right )} \cos \left (2 \, b x + 2 \, a\right ) - 3 \, {\left (\cos \left (2 \, b x + 2 \, a\right ) + i \, \sin \left (2 \, b x + 2 \, a\right ) + 1\right )} {\rm Li}_2\left (-e^{\left (2 i \, b x + 2 i \, a\right )}\right ) - 3 \, {\left (i \, b x \cos \left (2 \, b x + 2 \, a\right ) - b x \sin \left (2 \, b x + 2 \, a\right ) + i \, b x\right )} \log \left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right ) - {\left (b^{3} x^{3} + 6 i \, b^{2} x^{2}\right )} \sin \left (2 \, b x + 2 \, a\right )}{-3 i \, b^{3} \cos \left (2 \, b x + 2 \, a\right ) + 3 \, b^{3} \sin \left (2 \, b x + 2 \, a\right ) - 3 i \, b^{3}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x^2*tan(b*x+a)^2,x, algorithm="maxima")

[Out]

(I*b^3*x^3 + 6*(b*x*cos(2*b*x + 2*a) + I*b*x*sin(2*b*x + 2*a) + b*x)*arctan2(sin(2*b*x + 2*a), cos(2*b*x + 2*a
) + 1) + (I*b^3*x^3 - 6*b^2*x^2)*cos(2*b*x + 2*a) - 3*(cos(2*b*x + 2*a) + I*sin(2*b*x + 2*a) + 1)*dilog(-e^(2*
I*b*x + 2*I*a)) - 3*(I*b*x*cos(2*b*x + 2*a) - b*x*sin(2*b*x + 2*a) + I*b*x)*log(cos(2*b*x + 2*a)^2 + sin(2*b*x
 + 2*a)^2 + 2*cos(2*b*x + 2*a) + 1) - (b^3*x^3 + 6*I*b^2*x^2)*sin(2*b*x + 2*a))/(-3*I*b^3*cos(2*b*x + 2*a) + 3
*b^3*sin(2*b*x + 2*a) - 3*I*b^3)

________________________________________________________________________________________

Fricas [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 144 vs. \(2 (62) = 124\).
time = 0.40, size = 144, normalized size = 1.97 \begin {gather*} -\frac {2 \, b^{3} x^{3} - 6 \, b^{2} x^{2} \tan \left (b x + a\right ) - 6 \, b x \log \left (-\frac {2 \, {\left (i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1}\right ) - 6 \, b x \log \left (-\frac {2 \, {\left (-i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1}\right ) - 3 i \, {\rm Li}_2\left (\frac {2 \, {\left (i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1} + 1\right ) + 3 i \, {\rm Li}_2\left (\frac {2 \, {\left (-i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1} + 1\right )}{6 \, b^{3}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x^2*tan(b*x+a)^2,x, algorithm="fricas")

[Out]

-1/6*(2*b^3*x^3 - 6*b^2*x^2*tan(b*x + a) - 6*b*x*log(-2*(I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1)) - 6*b*x*log
(-2*(-I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1)) - 3*I*dilog(2*(I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1) + 1) +
 3*I*dilog(2*(-I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1) + 1))/b^3

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int x^{2} \tan ^{2}{\left (a + b x \right )}\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x**2*tan(b*x+a)**2,x)

[Out]

Integral(x**2*tan(a + b*x)**2, x)

________________________________________________________________________________________

Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x^2*tan(b*x+a)^2,x, algorithm="giac")

[Out]

integrate(x^2*tan(b*x + a)^2, x)

________________________________________________________________________________________

Mupad [F]
time = 0.00, size = -1, normalized size = -0.01 \begin {gather*} \int x^2\,{\mathrm {tan}\left (a+b\,x\right )}^2 \,d x \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(x^2*tan(a + b*x)^2,x)

[Out]

int(x^2*tan(a + b*x)^2, x)

________________________________________________________________________________________